//
//  MainCommentCell.m
//  soccer
//
//  Created by 上官千城 on 15/9/11.
//  Copyright (c) 2015年 上官千城. All rights reserved.
//

#import "OMainCommentCell.h"
#define allSize 10

@implementation OMainCommentCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatCell];
    }
    return self;
}



- (void)creatCell
{
    self.photoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(allSize, allSize, (self.contentView.frame.size.width - 2 * allSize) / 2, 2 * self.contentView.frame.size.height )];
    [self.photoImageView setBackgroundColor:[UIColor whiteColor]];
    [self.contentView addSubview:self.photoImageView];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.photoImageView.frame.size.width + 3 * allSize, allSize, (self.contentView.frame.size.width - 2 * allSize) / 2, self.contentView.frame.size.height)];
    [self.nameLabel setBackgroundColor:[UIColor whiteColor]];
    [self.contentView addSubview:self.nameLabel];
    
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.photoImageView.frame.size.width + 3 * allSize, self.contentView.frame.size.height + allSize, (self.contentView.frame.size.width - 2 * allSize) / 2, self.contentView.frame.size.height)];
    [self.timeLabel setBackgroundColor:[UIColor whiteColor]];
    [self.contentView addSubview:self.timeLabel];
    
 
    
}

-(void)setMainComment:(OMainComment *)mainComment
{
    if (_mainComment != mainComment) {
        _mainComment = mainComment;
    }
    NSURL *url = [NSURL URLWithString:mainComment.movieImageView];
    [self.photoImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"111111.png"]];
    
    self.nameLabel.text = [NSString stringWithFormat:@"%@", mainComment.nameLabel];
    self.nameLabel.numberOfLines = 2;
    [self.nameLabel sizeToFit];
    
    NSInteger minutes = (NSInteger)mainComment.length / 60;
    NSInteger seconds = (NSInteger)mainComment.length % 60;
    self.timeLabel.text = [NSString stringWithFormat:@"片长：%02ld分%02ld秒", minutes, seconds];
    self.timeLabel.textColor = [UIColor lightGrayColor];


}


@end
